package com.easylive.admin.controller;

import com.easylive.entity.enums.VideoStatusEnum;
import com.easylive.entity.po.VideoInfoPost;
import com.easylive.entity.query.VideoInfoPostQuery;
import com.easylive.entity.vo.PaginationResultVO;
import com.easylive.entity.vo.ResponseVO;
import com.easylive.service.VideoInfoFilePostService;
import com.easylive.service.VideoInfoPostService;
import com.easylive.service.VideoInfoService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/videoInfo")
@Validated
public class VideoInfoController extends ABaseController{

    @Resource
    private VideoInfoPostService videoInfoPostService;
    @Resource
    private VideoInfoFilePostService videoInfoFilePostService;
    @Resource
    private VideoInfoService videoInfoService;

    @RequestMapping("/loadVideoList")
    public ResponseVO loadVideoList(VideoInfoPostQuery query) throws Exception{
        query.setOrderBy("v.last_update_time desc");
        query.setQueryCountInfo(true);
        query.setQueryUserInfo(true);
        PaginationResultVO<VideoInfoPost> listByPage = videoInfoPostService.findListByPage(query);

        return getSuccessResponseVO(listByPage);

    }

    @RequestMapping("/auditVideo")
    public ResponseVO auditVideo(@NotEmpty String videoId,
                                 @NotNull Integer status,
                                 String reason) throws Exception{
        videoInfoPostService.auditVideo(videoId,status,reason);
        return getSuccessResponseVO(null);


    }

}
